package com.cloudcross.ssp.common.consts;

import java.util.ArrayList;
import java.util.List;

import com.adinall.dsp.core.data.KeyValueBeanOld;

/**
 * 媒体来源用枚举
 * 
 * @author 高万超
 * @version V1.0.0 $ 2017年6月21日 下午3:21:10
 */
public enum MediaSource {

    APP(1, "Mobile"),

    PC(0, "PC");

    public final int code;
    public final String name;

    MediaSource(int code, String name) {
        this.code = code;
        this.name = name;
    }

    public static MediaSource search(int code) {

        for (MediaSource e : values()) {

            if (e.code == code) {
                return e;
            }
        }

        return PC;
    }

    public static List<KeyValueBeanOld> list() {

        List<KeyValueBeanOld> data = new ArrayList<>();

        for (MediaSource e : values()) {
            data.add(new KeyValueBeanOld(e.code, e.name));
        }

        return data;
    }
}
